package com.bff.gaia.mix.api.xjoin2.partition;

import com.alibaba.fastjson.JSONObject;
import com.bff.gaia.api.common.functions.Partitioner;
import com.bff.gaia.api.java.tuple.Tuple5;
import com.bff.gaia.util.MathUtils;

public class AllXjoinPartitioner implements Partitioner<Tuple5<Integer,String,String,String,Integer>> {

	@Override
	public int partition(Tuple5<Integer,String,String,String,Integer> object, int numPartitions) {
		String key = object.getField(2);
		String action = object.getField(1);
		if (action.equalsIgnoreCase("end")) {
			return object.getField(4);
		} else {
			return MathUtils.murmurHash(key.hashCode()) % numPartitions;
		}

	}
}